﻿using BLL;
using Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PropertyAppraisal.ProjectInitiation
{
    public partial class LiXiangEdit : System.Web.UI.Page
    {
        //部门表
        private static DepartmentBll Depbll = new DepartmentBll();
        //借款人表
        private static Loan_InfoBll Loanbll = new Loan_InfoBll();
        //项目信息表
        private static Basic_InfoBll Basicbll = new Basic_InfoBll();
        string projectNumber = "";
        protected void Page_Load(object sender, EventArgs e)
        {
          
        }

        /// <summary>
        /// 反填信息
        /// </summary>
        /// <returns></returns>
        [WebMethod]
        public static string Edit(string projectNumber)
        {  
            var result = Basicbll.Edit(projectNumber);
            return JsonConvert.SerializeObject(result);
        }
        /// <summary>
        /// 获取所有用户信息
        /// </summary>
        /// <returns></returns>
        public static List<SysUser> UserList()
        {
            return new BLL.UsersBll().Show();
        }
        /// <summary>
        /// 用户下拉框
        /// </summary>
        /// <returns></returns>
        public static string surveyDB(int Roles_id)
        {
            var list = UserList().Where(n => n.Roles_id == Roles_id).ToList();
            var htmlstr = "";
            for (int i = 0; i < list.Count; i++)
            {
                htmlstr += "<option value=\"" + list[i].users_Id + "\">" + list[i].users_Name + "</option>";
            }
            return htmlstr;
        }


        /// <summary>
        /// 绑定部门下拉框
        /// </summary>
        /// <returns></returns>
        public static string departmentBD()
        {
            List<SysDepartment> dept = Depbll.DepartmentBD();
            var HtmlStr = "";
            for (var i = 0; i < dept.Count; i++)
            {
                HtmlStr += "<option value=\"" + dept[i].department_Id + "\">" + dept[i].department_Name + "</option>";
            }
            return HtmlStr;
        }
        /// <summary>
        /// 绑定报告类型下拉框
        /// </summary>
        /// <returns></returns>
        public static string BGTypeBD()
        {
            DictionaryBll Dictionarybll = new DictionaryBll();
            List<SysDictionary> Dictionary = Dictionarybll.sb(3);
            var HtmlStr = "";
            for (var i = 0; i < Dictionary.Count; i++)
            {
                HtmlStr += "<option value=\"" + Dictionary[i].Dictionary_Number + "\">" + Dictionary[i].dictionary_Name + "</option>";
            }
            return HtmlStr;
        }
        /// <summary>
        /// 绑定建成年代来源下拉框
        /// </summary>
        /// <returns></returns>
        public static string YersBD()
        {
            DictionaryBll Dictionarybll = new DictionaryBll();
            List<SysDictionary> Dictionary = Dictionarybll.sb(2);
            var HtmlStr = "";
            for (var i = 0; i < Dictionary.Count; i++)
            {
                HtmlStr += "<option value=\"" + Dictionary[i].Dictionary_Number + "\">" + Dictionary[i].dictionary_Name + "</option>";
            }
            return HtmlStr;
        }
        /// <summary>
        /// 绑定房屋用途下拉框
        /// </summary>
        /// <returns></returns>
        public static string DictionaryBD()
        {
            DictionaryBll Dictionarybll = new DictionaryBll();
            List<SysDictionary> Dictionary = Dictionarybll.sb(1);
            var HtmlStr = "";
            for (var i = 0; i < Dictionary.Count; i++)
            {
                HtmlStr += "<option value=\"" + Dictionary[i].Dictionary_Number + "\">" + Dictionary[i].dictionary_Name + "</option>";
            }
            return HtmlStr;
        }
        /// <summary>
        /// 修改 估价人员
        /// </summary>
        /// <param name="projectNumber">项目编号</param>
        /// <param name="ID">估价人员编号</param>
        /// <returns></returns>
        [WebMethod]
        public static bool UpdateEvaluation(string projectNumber,int ID)
        {
            return new BLL.Basic_InfoBll().UpdateEvaluation(projectNumber, ID);
        }
    }
}